using System; 
using System.Text; 
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration; 
using System.Xml; 
using System.Xml.Serialization;
using SubSonic; 
using SubSonic.Utilities;

namespace SurveyHost.Core.DAL{
    /// <summary>
    /// Strongly-typed collection for the SurveyInformation class.
    /// </summary>
    [Serializable]
    public partial class SurveyInformationCollection : ReadOnlyList<SurveyInformation, SurveyInformationCollection>
    {        
        public SurveyInformationCollection() {}

    }

    /// <summary>
    /// This is  Read-only wrapper class for the SurveyInformation view.
    /// </summary>
    [Serializable]
    public partial class SurveyInformation : ReadOnlyRecord<SurveyInformation> 
    {
    
	    #region Default Settings
	    protected static void SetSQLProps() 
	    {
		    GetTableSchema();
	    }

	    #endregion
        #region Schema Accessor
	    public static TableSchema.Table Schema
        {
            get
            {
                if (BaseSchema == null)
                {
                    SetSQLProps();
                }

                return BaseSchema;
            }

        }

    	
        private static void GetTableSchema() 
        {
            if(!IsSchemaInitialized)
            {
                //Schema declaration
                TableSchema.Table schema = new TableSchema.Table("SurveyInformation", TableType.View, DataService.GetInstance("SurveyHost"));
                schema.Columns = new TableSchema.TableColumnCollection();
                schema.SchemaName = "dbo";
                //columns
                
                TableSchema.TableColumn colvarUserId = new TableSchema.TableColumn(schema);
                colvarUserId.ColumnName = "UserId";
                colvarUserId.DataType = DbType.Guid;
                colvarUserId.MaxLength = 0;
                colvarUserId.AutoIncrement = false;
                colvarUserId.IsNullable = false;
                colvarUserId.IsPrimaryKey = false;
                colvarUserId.IsForeignKey = false;
                colvarUserId.IsReadOnly = false;
                
                schema.Columns.Add(colvarUserId);
                
                TableSchema.TableColumn colvarConsentDate = new TableSchema.TableColumn(schema);
                colvarConsentDate.ColumnName = "ConsentDate";
                colvarConsentDate.DataType = DbType.DateTime;
                colvarConsentDate.MaxLength = 0;
                colvarConsentDate.AutoIncrement = false;
                colvarConsentDate.IsNullable = false;
                colvarConsentDate.IsPrimaryKey = false;
                colvarConsentDate.IsForeignKey = false;
                colvarConsentDate.IsReadOnly = false;
                
                schema.Columns.Add(colvarConsentDate);
                
                TableSchema.TableColumn colvarBeginTime = new TableSchema.TableColumn(schema);
                colvarBeginTime.ColumnName = "BeginTime";
                colvarBeginTime.DataType = DbType.DateTime;
                colvarBeginTime.MaxLength = 0;
                colvarBeginTime.AutoIncrement = false;
                colvarBeginTime.IsNullable = false;
                colvarBeginTime.IsPrimaryKey = false;
                colvarBeginTime.IsForeignKey = false;
                colvarBeginTime.IsReadOnly = false;
                
                schema.Columns.Add(colvarBeginTime);
                
                TableSchema.TableColumn colvarEndTime = new TableSchema.TableColumn(schema);
                colvarEndTime.ColumnName = "EndTime";
                colvarEndTime.DataType = DbType.DateTime;
                colvarEndTime.MaxLength = 0;
                colvarEndTime.AutoIncrement = false;
                colvarEndTime.IsNullable = true;
                colvarEndTime.IsPrimaryKey = false;
                colvarEndTime.IsForeignKey = false;
                colvarEndTime.IsReadOnly = false;
                
                schema.Columns.Add(colvarEndTime);
                
                TableSchema.TableColumn colvarCompleted = new TableSchema.TableColumn(schema);
                colvarCompleted.ColumnName = "Completed";
                colvarCompleted.DataType = DbType.Boolean;
                colvarCompleted.MaxLength = 0;
                colvarCompleted.AutoIncrement = false;
                colvarCompleted.IsNullable = false;
                colvarCompleted.IsPrimaryKey = false;
                colvarCompleted.IsForeignKey = false;
                colvarCompleted.IsReadOnly = false;
                
                schema.Columns.Add(colvarCompleted);
                
                
                BaseSchema = schema;
                //add this schema to the provider
                //so we can query it later
                DataService.Providers["SurveyHost"].AddSchema("SurveyInformation",schema);
            }

        }

        #endregion
        
        #region Query Accessor
	    public static Query CreateQuery()
	    {
		    return new Query(Schema);
	    }

	    #endregion
	    
	    #region .ctors
	    public SurveyInformation()
	    {
            SetSQLProps();
            SetDefaults();
            MarkNew();
        }

        public SurveyInformation(bool useDatabaseDefaults)
	    {
		    SetSQLProps();
		    if(useDatabaseDefaults)
		    {
				ForceDefaults();
			}

			MarkNew();
	    }

	    
	    public SurveyInformation(object keyID)
	    {
		    SetSQLProps();
		    LoadByKey(keyID);
	    }

    	 
	    public SurveyInformation(string columnName, object columnValue)
        {
            SetSQLProps();
            LoadByParam(columnName,columnValue);
        }

        
	    #endregion
	    
	    #region Props
	    
          
        [XmlAttribute("UserId")]
        public Guid UserId 
	    {
		    get
		    {
			    return GetColumnValue<Guid>("UserId");
		    }

            set 
		    {
			    SetColumnValue("UserId", value);
            }

        }

	      
        [XmlAttribute("ConsentDate")]
        public DateTime ConsentDate 
	    {
		    get
		    {
			    return GetColumnValue<DateTime>("ConsentDate");
		    }

            set 
		    {
			    SetColumnValue("ConsentDate", value);
            }

        }

	      
        [XmlAttribute("BeginTime")]
        public DateTime BeginTime 
	    {
		    get
		    {
			    return GetColumnValue<DateTime>("BeginTime");
		    }

            set 
		    {
			    SetColumnValue("BeginTime", value);
            }

        }

	      
        [XmlAttribute("EndTime")]
        public DateTime? EndTime 
	    {
		    get
		    {
			    return GetColumnValue<DateTime?>("EndTime");
		    }

            set 
		    {
			    SetColumnValue("EndTime", value);
            }

        }

	      
        [XmlAttribute("Completed")]
        public bool Completed 
	    {
		    get
		    {
			    return GetColumnValue<bool>("Completed");
		    }

            set 
		    {
			    SetColumnValue("Completed", value);
            }

        }

	    
	    #endregion
    
	    #region Columns Struct
	    public struct Columns
	    {
		    
		    
            public static string UserId = @"UserId";
            
            public static string ConsentDate = @"ConsentDate";
            
            public static string BeginTime = @"BeginTime";
            
            public static string EndTime = @"EndTime";
            
            public static string Completed = @"Completed";
            
	    }

	    #endregion
    }

}

